<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!--  准备好一个容器  -->
    <div id="test1"></div>
    <div id="test2"></div>
    <div id="test3"></div>


    <!--  引入react核心库  -->
    <script type="text/javascript" src="../../js_base/react.development.js"></script>
    <script type="text/javascript" src="../../js_base/react-dom.development.js"></script>
    <script type="text/javascript" src="../../js_base/babel.min.js"></script>

    <script type="text/babel">
        // 创建组件
        class Person extends React.Component {
            render(){
                return (
                    <ul>
                        <li>姓名：{this.props.name}</li>
                        <li>性别：{this.props.sex}</li>
                        <li>年龄：{this.props.age}</li>
                    </ul>
                )
            }
        }
        // 渲染组件到页面
        ReactDOM.render(<Person name='tom' age='18' sex='男'/>, document.getElementById("test1"))
        ReactDOM.render(<Person name='jerry' age='19' sex='女'/>, document.getElementById("test2"))
        // ReactDOM.render(<Person name='dog' age='20' sex='男'/>, document.getElementById("test3"))

        const p = {name:'dog',age:'20',sex:'男'}
        // react + babel允许展开运算符作用于对象，但仅限于标签中，标签以外的地方无法获取到展开结果，此处打印结果为空
        console.log("@", ...p)
        ReactDOM.render(<Person {...p}/>, document.getElementById("test3"))
    </script>

</body>
</html>